/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package invitator;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 *
 * @author muller
 */
public class JsTest {
    
    
    public static void main(String args[]){
        ScriptEngineManager factory = new ScriptEngineManager();
        ScriptEngine engine = factory.getEngineByName("JavaScript");
        String js = new String();
        
        js+= "importPackage(java.io);";
        js+= "importPackage(java.lang);";
        js+= "importPackage(Packages.invitator.mail);";
        js+= "var mmb = new MessageMailBean();";
        
        System.out.println(js);
        try {
            engine.eval(js);
        } catch (ScriptException ex) {
            Logger.getLogger(JsTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
     public static void mainn(String[] args) throws Exception {
        // create a script engine manager
        ScriptEngineManager factory = new ScriptEngineManager();
        // create a JavaScript engine
        ScriptEngine engine = factory.getEngineByName("JavaScript");
        // evaluate JavaScript code from String
//         engine.eval(""
//                 + "importPackage(invitator.JsTest);\n"
//                 + "print('Welocme to java world\\n');\n"
//                 + "JsTest.sayHi();");
        
//        engine.eval("importPackage(java.io);"
//                + "importPackage(java.lang);"
//                + "var reader = new BufferedReader( new InputStreamReader(System['in']) );"
//                + "var s = true;"
//                + "while (s) {"
//                + "   s = reader.readLine();"
//                + "    if (s) {"
//                + "        System.out.println(s.toUpperCase());"
//                + "    }"
//                + "}");
//           engine.eval("importPackage(java.io);"
//                + "importPackage(java.lang);"
//                + "        System.out.println('lll');"
//                + "");
        
//        engine.eval("importPackage(java.io);"
//                + "importPackage(java.lang);"
//                + "importPackage(Packages.invitator);"
//                + "        JsTest.sayHi();"
//                + "");
        
        engine.eval("importPackage(java.io);"
                + "importPackage(java.lang);"
                + "importPackage(Packages.invitator);"
                + "      var lol = new JsTest();"
                + " lol.sayHi();"
                + "");
    }

    public static void sayHi() {
        System.out.println("hihi");
    }

}
